package com.xcdh.domain.vo;

import com.xcdh.domain.entity.DeptDO;
import lombok.SneakyThrows;
import org.springframework.beans.BeanUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * TypeA2B
 * Created by wjg on 2024/1/6.
 */
public class TypeValueA2B {

    @SneakyThrows
    public static <T> T a2b(Object bean , Class<T> clazz){
        T t = clazz.newInstance();
        BeanUtils.copyProperties(bean, t);
        return t ;
    }

    public static void main(String[] args) {
        DeptDO deptDO = new DeptDO() ;
        deptDO.setDeptId("12L");
        DeptDO deptDO2 = new DeptDO() ;
        deptDO.setDeptId("13L");
        List<DeptDO> list = Arrays.asList(deptDO, deptDO2);

        Map<String, List<DeptDO>> collect = list.stream().collect(Collectors.groupingBy(DeptDO::getDeptId));
    }
}
